<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>

<body>
    <script>
        // 1数组的合并
        // es5中的写法 
        // var arr = [1, 2, 3]
        // var arr1 = [4, 5, 6]
        // var arr2 = arr.concat(arr1);
        // console.log(arr2)
        // console.log(arr)
        // console.log(arr1)


        // es6中写法
        let a = ["q", "w", "e",]
        let b = ["a", "s", "d"]
        let arr1 = [...a, ...b]
        console.log(arr1)
        console.log(a, b)


        // 2伪数组转数组
        let set = new Set([1, 2, 3])
        let arr2 = [...set]
        console.log(arr2)


        // 数组浅拷贝
        let arr3 = [1, 2, 3, 4, 5, ["age", "name"]]
        let arr4 = [...arr3]
        // console.log(arr4)
        arr3[5][0] = "张三";
        console.log(arr3)
        console.log(arr4)

        arr3[0] = "李四"
        console.log(arr3)
        console.log(arr4)


        // 实现对象的浅拷贝
        let obj = {
            name: "清许",
            age: 24,
            hobbies: ["打羽毛球", "购物"]
        }
        let obj1 = { ...obj }
        // console.log(obj)
        // console.log(obj1)
        obj.name = "初见"
        console.log(obj)
        console.log(obj1)
        obj.hobbies[0] = "丢沙包"
        console.log(obj)
        console.log(obj1)



    </script>
</body>

</html>